package com.jack.jetpackapp

import org.junit.Test
import java.lang.ref.ReferenceQueue
import java.lang.ref.WeakReference

/**
 * @author Jack 2021-05-09 10:57
 */
class ReferenceTest {

    private val rq = ReferenceQueue<Any?>()

    @Test
    fun main() {
        var obj: Any? = Any()
        val sf = WeakReference(obj, rq)
        println(sf.get().toString())
        obj = null
        Runtime.getRuntime().gc()
        println(rq.remove())
    }
}